package com.teatrace.model.sell;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

import com.teatrace.model.base.Device;
import com.teatrace.model.base.Employee;

@Entity
public class Delivery {
	@Id
	@Column(name="delivery_id")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
    private long id;//发货编号 <无用>
	
    private String description;//描述
    @Column(columnDefinition="datetime")
    private Date time;//发货时间
    
    @OneToMany(mappedBy="delivery")
    private Set<Order> orders;// 订单号
    
    @ManyToMany(cascade={CascadeType.ALL})
	@JoinTable(
		name="r_device_delivery",
		joinColumns={@JoinColumn(name="delivery_id")},
		inverseJoinColumns={@JoinColumn(name="device_id")}
	)
	private Set<Device> devices;

	@ManyToMany
	@JoinTable(
		name="r_employee_delivery",
		joinColumns={@JoinColumn(name="delivery_id")},
		inverseJoinColumns={@JoinColumn(name="employee_id")}
	)
	private Set<Employee> emps;
    
    private int deleted;
     
    /**
     * get ; set;
     * @return
     */
	public int getDeleted() {
		return deleted;
	}
	public void setDeleted(int deleted) {
		this.deleted = deleted;
	}
	public Set<Order> getOrders() {
		return orders;
	}
	public void setOrders(Set<Order> orders) {
		this.orders = orders;
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	public Set<Device> getDevices() {
		return devices;
	}
	public void setDevices(Set<Device> devices) {
		this.devices = devices;
	}
	public Set<Employee> getEmps() {
		return emps;
	}
	public void setEmps(Set<Employee> emps) {
		this.emps = emps;
	}
}
